package com.sun.designPattern.Observer.ProjectImp;

import java.util.Observer;
import java.util.UUID;


public class ObserverDemo {
	private static EntityEventBlock e = EntityEventBlock.instance();
	static {
		Observer o = new TstObServer();
		e.addObserver(o);
	}
	
	public static void main(String[] args) {
		
		Student s1 = new Student();
		s1.setId(UUID.randomUUID().toString());
		add(s1);
		Student s2 = new Student();
		s2.setId(UUID.randomUUID().toString());
		add(s2);
		s2.setName("new name");
		update(s2);
		e.notifyObservers("aaa");
	}

	static void update(Entity entity) {
		e.makeUpdateEvent(entity.getClass(), entity.getId());

	}

	static void add(Entity entity) {
		e.makeAddEvent(entity.getClass(), entity.getId());
	}

	static void delete(Entity entity) {
		e.makeDelEvent(entity.getClass(), entity.getId());
	}
}
